//
//  MyMoneyBottomCell.m
//  ShangHaiTuJI
//
//  Created by xiaoxiangtuji on 2017/9/30.
//  Copyright © 2017年 xiaoxiangtuji. All rights reserved.
//

#import "MyMoneyBottomCell.h"
#import "RecordListModel.h"
@implementation MyMoneyBottomCell

- (void)awakeFromNib {
    [super awakeFromNib];
    // Initialization code
}

-(void)setModel:(RecordListModel *)model{
    _model = model;
    UILabel *nameLabel = [[UILabel alloc] init];
    nameLabel.font = [UIFont systemFontOfSize:14];
    if ([[NSUserDefaults standardUserDefaults] objectForKey:@"NAME"]) {
        nameLabel.text = [[NSUserDefaults standardUserDefaults] objectForKey:@"NAME"];
    }
//    NSString *str = @"小凯";
//    NSMutableAttributedString *attriStr = [[NSMutableAttributedString alloc] initWithString:str];
////    [attriStr addAttribute:NSForegroundColorAttributeName value:COLOR_HEX(0xFD5844) range:NSMakeRange(attriStr.length - 9, 9)];
////    [attriStr addAttribute:NSFontAttributeName value:[UIFont systemFontOfSize:11] range:NSMakeRange(attriStr.length - 9, 9)];
//    nameLabel.attributedText = attriStr;
    [self.contentView addSubview:nameLabel];
    [nameLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(self.contentView.mas_left).offset(12);
        make.top.equalTo(self.contentView.mas_top).offset(20);
        make.height.mas_equalTo(30);
        make.right.equalTo(self.contentView.mas_right).offset(-12);
    }];
     
    UILabel *daysLabel = [[UILabel alloc] init];
    NSString *timeStr = [NSString stringWithFormat:@"%@",model.time];
    NSLog(@"时间戳%@",timeStr);
    daysLabel.text = [self timeBackAccoringValue:timeStr];
    daysLabel.textAlignment = NSTextAlignmentRight;
    daysLabel.textColor = COLOR_HEX(0xB9B9B9);
    daysLabel.font = [UIFont systemFontOfSize:11];
    [self.contentView addSubview:daysLabel];
    [daysLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.size.mas_equalTo(CGSizeMake(150, 10));
        make.top.equalTo(nameLabel.mas_bottom).offset(5);
        make.right.equalTo(self.contentView.mas_right).offset(-12);
    }];
     
    UILabel *recordLabel = [[UILabel alloc] init];
    recordLabel.text = [NSString stringWithFormat:@"连续签到%@天,获得了1枚金币",model.seriesDay];
    recordLabel.textColor = COLOR_HEX(0x777777);
    recordLabel.font = [UIFont systemFontOfSize:12];
    [self.contentView addSubview:recordLabel];
    [recordLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.right.equalTo(daysLabel.mas_left).offset(-5);
        make.top.equalTo(nameLabel.mas_bottom).offset(5);
        make.left.equalTo(self.contentView.mas_left).offset(12);
        make.height.mas_equalTo(12);
    }];
}

/**
 时间戳转时间

 */
-(NSString *)timeBackAccoringValue:(NSString *)timestap{
    NSDateFormatter *formatter = [[NSDateFormatter alloc] init];
    [formatter setDateStyle:NSDateFormatterMediumStyle];
    [formatter setTimeStyle:NSDateFormatterShortStyle];
    [formatter setDateFormat:@"YYYY-MM-dd HH:mm:ss"];
     NSTimeZone* timeZone = [NSTimeZone timeZoneWithName:@"Asia/Shanghai"];
    [formatter setTimeZone:timeZone];
    NSDate *confromTimesp = [NSDate dateWithTimeIntervalSince1970:[timestap integerValue]/1000];//现在时间,你可以输出来看下是什么格式
    NSLog(@"这是现%@",confromTimesp);
    NSString *nowtimeStr = [formatter stringFromDate:confromTimesp];
    NSLog(@"这是现在的时间吗%@",nowtimeStr);
    return nowtimeStr;
}
//-(NSString *)timestampSwitchTime:(NSInteger)timestamp{
//
//
//
//    NSDateFormatter *formatter = [[NSDateFormatter alloc] init];
//
//    [formatter setDateStyle:NSDateFormatterMediumStyle];
//
//    [formatter setTimeStyle:NSDateFormatterShortStyle];
//
//    [formatter setDateFormat:@"YYYY-MM-dd HH:mm:ss"]; // （@"YYYY-MM-dd hh:mm:ss"）----------设置你想要的格式,hh与HH的区别:分别表示12小时制,24小时制
//
//    NSTimeZone *timeZone = [NSTimeZone timeZoneWithName:@"Asia/Beijing"];
//
//    [formatter setTimeZone:timeZone];
//
//    NSDate *confromTimesp = [NSDate dateWithTimeIntervalSince1970:timestamp];
//
//
//
//
//
//    NSString *confromTimespStr = [formatter stringFromDate:confromTimesp];
//
//
//
//    //NSLog(@"&&&&&&&confromTimespStr = : %@",confromTimespStr);
//        NSLog(@"1508635207000 = %@",confromTimespStr);
//
//
//    return confromTimespStr;
//
//}
//

    
    


- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
    [super setSelected:selected animated:animated];

    // Configure the view for the selected state
}

@end
